Skip to content

Save Codex local changes#50

Merged
BigSimmo merged 3 commits into
mainfrom
codex/database-safe-save
Jun 23, 2026
Merged

Save Codex local changes#50
BigSimmo merged 3 commits into
mainfrom
codex/database-safe-save

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Saves local Codex changes for review.

Copilot AI review requested due to automatic review settings June 23, 2026 02:24
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@BigSimmo
BigSimmo merged commit e980404 into main Jun 23, 2026
6 of 8 checks passed
@BigSimmo
BigSimmo deleted the codex/database-safe-save branch June 23, 2026 02:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aggregates a broad set of “local Codex changes” spanning worker ingestion/indexing behavior, Supabase schema hardening (health checks, indexes, dedup), clinical output formatting, UI accessibility/table rendering, and process/CI guardrails (verification scripts + Playwright coverage + production readiness preflight).

Changes:

  • Add embedding-field dedup support (content_hash + trigger + unique index), expand schema health/index validation, and refresh table stats post-ingestion.
  • Improve RAG/clinical UX output: smarter bottom-line selection, clipboard/note formatting, evidence passage compaction, and safety finding text cleanup.
  • Harden process: new verification commands, CI Playwright Chromium smoke, production-readiness preflight, security headers, and new Playwright UI/accessibility tests.

Reviewed changes

Copilot reviewed 107 out of 120 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
worker/main.ts Adds embedding-field content_hash, larger insert batching, and post-job analyze_rag_tables refresh.
worker/embedding-fields.ts Formatting-only adjustment to addField call.
tests/ward-output.test.ts Updates assertions for new clipboard/ward-note formatting and section merging behavior.
tests/ui-tools.spec.ts Adds Playwright coverage for /tools launcher usability.
tests/ui-smoke.spec.ts Stabilizes selectors and updates upload drawer interactions for new UI structure.
tests/ui-accessibility.spec.ts Adds reduced-motion + forced-colors Playwright smoke coverage.
tests/supabase-schema.test.ts Loosens grants regex to accommodate new schema items.
tests/private-access-routes.test.ts Formatting-only change to route handler invocation.
tests/ingestion.test.ts Formatting-only change to long error string literal.
tests/evidence.test.ts Formatting-only change to array expectation.
tests/embed-texts-integrity.test.ts Formatting-only change to mock embedding data creation.
tests/deep-memory.test.ts Formatting-only tweaks; removes stray whitespace.
tests/clinical-safety.test.ts Updates expectations for cleaned safety finding labels/text; adds new test.
tests/bulk-import.test.ts Formatting-only tweak to expected array literal.
tests/answer-verification.test.ts Formatting-only change to function call layout.
tests/accessible-table-normalization.test.ts Adds a source-based regression test for updated AccessibleTable structure.
supabase/migrations/20260623014639_finalize_embedding_fields_hnsw_health.sql Finalizes schema-health expectations and adds embedding-fields HNSW index + health RPC update.
supabase/migrations/20260622000000_reconcile_schema_health_vector_privileges.sql Adds index reconciliation, embedding-field hash trigger + dedup index, RPC hardening, and analyze_rag_tables.
src/lib/ward-output.ts Major rework of clipboard/ward-note output structure and bottom-line selection logic.
src/lib/supabase/health.ts Formatting-only adjustments in type signatures and HTML title extraction.
src/lib/rag.ts Adds additional retrieval telemetry counters and minor formatting fixes.
src/lib/openai.ts Formatting-only adjustment to PublicApiError construction.
src/lib/ingestion.ts Formatting-only refactor of retryable-error regex check.
src/lib/ingestion-recovery.ts Formatting-only change to boolean expression layout.
src/lib/image-filtering.ts Formatting-only refactor of condition wrapping.
src/lib/extractors/document.ts Formatting-only change to warning string push.
src/lib/env.ts Changes default worker runtime parameters (polling, batch size, concurrency, attempts, stale window).
src/lib/deep-memory.ts Increases batch sizes for deep-memory inserts and minor formatting.
src/lib/clinical-vocabulary.ts Expands formatting for readability of vocabulary entries.
src/lib/clinical-safety.ts Cleans/compacts extracted safety finding text using sanitizer helpers.
src/lib/bulk-import.ts Formatting-only change to normalized key assignment.
src/lib/answer-ranking.ts Comment whitespace cleanup.
src/lib/answer-formatting.ts Adds semicolon-list splitter helper and standardizes fallback text.
src/components/DocumentViewer.tsx Improves mobile actions UX (sheet), table rendering behavior, and copy changes (“Open source”).
src/components/DashboardFloatingFab.tsx Minor string quoting and SR live-region formatting adjustments.
src/components/clinical-dashboard/use-theme.ts Adds a client theme hook using useSyncExternalStore.
src/components/clinical-dashboard/source-actions.tsx Adds source action row + link helpers for dashboard usage.
src/components/clinical-dashboard/relevance.tsx Adds relevance badges/chips utilities and components.
src/components/clinical-dashboard/index.ts Exports the clinical-dashboard module surface.
src/components/clinical-dashboard/ClinicalDashboard.tsx Provides compatibility export for ClinicalDashboard.
src/components/clinical-dashboard/badges.tsx Adds status/strength badge components.
src/components/clinical-dashboard/answer-status.tsx Adds empty/skeleton/copy UI helpers for dashboard answer states.
src/components/AccessibleTable.tsx Reworks mobile table presentation to keep a single semantic table + adds expand dialog + row actions.
src/app/page.tsx Switches to importing ClinicalDashboard from the new module entrypoint.
src/app/api/search/route.ts Adds rag_retrieval_logs insert diagnostics with failure metrics tracking.
src/app/api/ingestion/jobs/[id]/retry/route.ts Formatting-only change to JSON error field layout.
scripts/supabase-recovery-status.ts Formatting-only refactor of safeCount calls.
scripts/reindex-health.ts Formatting-only refactor of safeCount calls.
scripts/production-readiness.ts Adds an executable production readiness preflight script.
scripts/playwright-base-url.ts Increases local identity probe timeout.
scripts/import-documents.ts Formatting-only console.log line wrapping changes.
scripts/eval-search.ts Adds retry/backoff on rate limits + spacing delay between cases.
scripts/eval-retrieval.ts Formatting-only change to a long numeric expression.
scripts/ensure-local-server.mjs Improves project identity probing robustness (retries + timeout).
scripts/enrich-documents.ts Adds retry/backoff on rate limits and better enrichment completion stamping.
scripts/check-indexing.ts Adds paginated document loading + ordering and more readiness reporting.
scripts/backfill-smart-index.ts Adds embedding-field md5 hash inclusion and small formatting fixes.
scripts/audit-tables.ts Formatting-only change to .or(...) usage.
scratch/update-health-check.sql Adds a scratch SQL version of search_schema_health updates.
scratch/show-samples.ts Adds a scratch script to print sample documents.
scratch/queue-queued-docs.ts Adds a scratch script to enqueue ingestion jobs for queued documents.
scratch/fix-indexes.ts Adds a scratch script stub for index fixes.
scratch/create-hnsw-indexes.sql Adds scratch SQL for creating HNSW indexes via dashboard/editor.
scratch/count-status.ts Adds scratch script to count document/job statuses.
scratch/count-files.ts Adds scratch script with local Windows paths for file counting.
scratch/check-queued-docs.ts Adds scratch script to inspect active ingestion jobs.
scratch/check-indexes.ts Adds scratch script attempting to query system indexes via Supabase.
scratch/audit-guidelines.ts Adds scratch script with local Windows paths for auditing guideline coverage.
README.md Documents new verification/readiness commands.
playwright.config.ts Expands test match to include accessibility/tools and increases timeout.
package.json Adds verify and production-readiness scripts plus workflow helpers.
next.config.ts Adds security headers (CSP, COOP/COEP, HSTS, etc.) and disables powered-by header.
eslint.config.mjs Ignores scratch/**.
docs/redesign/06-verification.md Records verification steps and results for redesign/process pass.
docs/redesign/05-changelog.md Adds June 23 process hardening notes.
docs/redesign/04-deferred.md Updates deferred items to reflect tools page coverage resolution.
docs/redesign/03-decision-log.md Adds decisions D7–D10 related to scope, upload drawer, viewer actions, evidence hint.
docs/redesign/02-design-direction.md Adds June 20 scoped direction notes.
docs/redesign/01-audit.md Adds audit notes emphasizing scoped run exclusions.
docs/production-readiness-checklist.md Adds executable production readiness checklist/runbook.
docs/process-hardening.md Adds verification gating plan and phases.
docs/clinical-governance.md Adds PR preflight guidance for governance-sensitive changes.
AGENTS.md Adds process-hardening guidance and verification gates for future agents.
.vscode/extensions.json Adds recommended dev extensions.
.tmp-visual/stream-headers.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/stream-capture.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-smoke.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-final.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-disabled-state.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-ask.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-ask-submit.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-api-trace.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/query-answer-stream.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/inspect-home.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/inspect-ask-controls.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/check-search-api.mjs Adds local visual/debug helper script (repo-local).
.tmp-visual/capture.mjs Adds local visual/debug helper script (repo-local).
.prettierignore Ignores .tmp-visual/ and scratch/.
.github/workflows/codeql.yml Formatting-only YAML cleanup.
.github/workflows/ci.yml Adds production-readiness CI check + installs/runs Playwright Chromium smoke.
.github/pull_request_template.md Adds verification checklist + clinical governance preflight section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +437 to +439
top_rrf_score: topResult?.rrf_score ?? null,
mean_hybrid_score: meanScore || null,
selected_chunk_ids: args.results
Comment on lines +439 to +446
selected_chunk_ids: args.results
.slice(0, 12)
.map((r) => r.id)
.filter((id) => /^[0-9a-f-]{36}$/i.test(id)),
selected_document_ids: Array.from(new Set(args.results.slice(0, 12).map((r) => r.document_id))).filter((id) =>
/^[0-9a-f-]{36}$/i.test(id),
),
selected_count: Math.min(args.results.length, 12),
Comment thread src/lib/env.ts
Comment on lines +64 to +68
WORKER_POLL_MS: z.coerce.number().int().positive().default(1500),
WORKER_BATCH_SIZE: z.coerce.number().int().positive().default(25),
WORKER_CONCURRENCY: z.coerce.number().int().positive().default(8),
WORKER_MAX_ATTEMPTS: z.coerce.number().int().positive().default(5),
WORKER_STALE_AFTER_MINUTES: z.coerce.number().int().positive().default(5),
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
…rank score

The 2026-07-20 post-merge golden run (eval-canary #50, 35/36) showed the
#982 tie-break regressing alcohol-ciwa-threshold: keying saturated ties on
the boost-laden rankScore let generic clinicalSignalBoost stacking promote
screening/monitoring chunks over the chunk containing the queried terms —
the same failure mode the clamped-score contract exists to prevent. The
tie-break key is now the clinical rank's lexicalCoverageScore (query-term
coverage, immune to boost stacking), renamed contentCoverageScore; ties on
coverage still fall back to the stable chunk-id order. The saturated-tie
contract test now pins coverage winning against a HIGHER rankScore, and
the fast-path CIWA guard adds the screening-chunk shape from run #50.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
BigSimmo added a commit that referenced this pull request Jul 20, 2026
…rank score (#987)

* fix(rag): break saturated selection ties by query-term coverage, not rank score

The 2026-07-20 post-merge golden run (eval-canary #50, 35/36) showed the
#982 tie-break regressing alcohol-ciwa-threshold: keying saturated ties on
the boost-laden rankScore let generic clinicalSignalBoost stacking promote
screening/monitoring chunks over the chunk containing the queried terms —
the same failure mode the clamped-score contract exists to prevent. The
tie-break key is now the clinical rank's lexicalCoverageScore (query-term
coverage, immune to boost stacking), renamed contentCoverageScore; ties on
coverage still fall back to the stable chunk-id order. The saturated-tie
contract test now pins coverage winning against a HIGHER rankScore, and
the fast-path CIWA guard adds the screening-chunk shape from run #50.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9

* docs(ledger): record run-#50 finding and coverage tie-break review row

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9

---------

Co-authored-by: Claude <noreply@anthropic.com>
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
…ck, WebKit focus/forced-colors/stale-style, Firefox tab order, CIWA term alias

Seven fixes from the run-4012 triage, each root-caused:

- playwright.config.ts: serviceWorkers 'block' suite-wide (+ ui-pwa.spec.ts
  'allow' opt-in). In production builds public/sw.js registers in every
  test, claims the page (clients.claim) and serves every navigation —
  probe-proven to bypass route interception for navigations on Chromium
  and to wedge Playwright-Firefox's reload path under an active route
  (both ui-smoke reload hangs). Only ui-pwa exercises the worker itself;
  its offline/CacheStorage journey passes under the opt-in.
- master-search-header.tsx: close the desktop mode menu on Tab from the
  trigger (APG menu-button pattern). WebKit's sequential focus navigation
  can fail to deliver a wrapper-escaping focusout (links excluded from
  its Tab order; backward wrap into the menu), leaving the menu open.
- ui-accessibility.spec.ts: webkit skip for the forced-colors token test —
  WebKit has no forced-colors implementation, so the media remap under
  test cannot engage there.
- ui-formulation.spec.ts: pin the step-nav Previous button enabled with
  opacity 1 before the axe scan — WebKit can serve a stale :disabled
  computed style whose 0.4 opacity axe folds into a phantom contrast
  violation for a WCAG-1.4.3-exempt state.
- ui-smoke.spec.ts: step over Firefox's scrollable-container tab stop
  (the sheet body sits between Close and 'New chat' in DOM order).
- scripts/eval-retrieval.ts: ciwa -> ciwa-ar content alias. The matcher
  is whitespace-delimited, so the bare fixture term can never match the
  scale's hyphenated written name; canary runs #50/#51 ranked the
  CIWA-Ar dosing-table region top-5 yet the gate reported a miss.
- tests/helpers/zero-touch.ts: shared stubZeroTouchPoints helper
  replacing the six inline copies from #995 (review follow-up).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants